Defines a subindex, an index definition subordinate to another index definition, its parent.

Namespace:  C1.LiveLinq.Indexing
Assembly:  C1.LiveLinq (in C1.LiveLinq.dll)

Syntax

C#
public abstract class Subindex<T, TKey> : Subindex<T>
Visual Basic
Public MustInherit Class Subindex(Of T, TKey) _
	Inherits Subindex(Of T)

Type Parameters

T
The type of the elements of the collection to index.
TKey
The type of the index key.

Remarks

An index (Index<(Of <(<'T, TKey>)>)>) can have subindexes. Subindexes are optional, not required for any indexing tasks, but can provide additional optimization and help minimize memory requirements when a collection is indexed by multi-level (multi-field) keys.

Suppose we want to index a Customers table by two fields, (City, Rating), perhaps for speeding up queries like

Copy CodeC#
from c in Customers where c.City == "London" && c.Rating == 1 select c
We can do it by defining an index with key selector c => new { c.City, c.Rating } , that will index the table by two fields, creating a multi-field index. Such index will suffice for optimizing the query above, but it will not optimize, for example, the following query:
Copy CodeC#
from c in Customers where c.City == "London" && c.Rating > 2 select c
Also, multi-field indexes occupy more memory than necessary because they have to store repeated field values.

Subindexes provide a better alternative for optimizing multi-field searches. In the example above, we can define an index by City and create a subindex of that index, by Rating. Using subindexes becomes even more effective when, as it is often happens, we also need queries to search by additional fields, like, for example, if we need to search by ContactTitle inside a city in addition to the search by Rating inside a city:

Copy CodeC#
from c in Customers where c.City == "London" && c.ContactTitle == "Owner" select c
All we have to do now is to add a second subindex to the index by City, a subindex by ContactTitle.

Inheritance Hierarchy

System..::..Object
  C1.LiveLinq.Indexing..::..IndexDefinition<(Of <(<'T>)>)>
    C1.LiveLinq.Indexing..::..Subindex<(Of <(<'T>)>)>
      C1.LiveLinq.Indexing..::..Subindex<(Of <(<'T, TKey>)>)>

See Also